<?php

namespace app\api\model;

use app\api\service\Api;
use think\Db;
use think\Request;

class OrderInsuredModel extends Api
{
    protected static $instance;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
    }

    public static function getInstance()
    {
        if (is_null(self::$instance))
        {
            self::$instance = new static();
        }
        return self::$instance;
    }

    /**
     * 获取一条记录
     */
    public function find($numId, $field = '*')
    {
        return Db::name('order_insured')->where([
            'num_id' => ['eq', $numId]
        ])->field($field)->find();
    }

    /**
     * 获取一列数据
     */
    public function column($where, $field = 'name')
    {
        return Db::name('order_insured')->where($where)->column($field, 'num_id');
    }

    /**
     * 获取一个字段
     */
    public function value($numId, $field = 'name')
    {
        return Db::name('order_insured')->where([
            'num_id' => ['eq', $numId]
        ])->value($field);
    }

    /**
     * 查询多条记录
     */
    public function select($where, $field = '*', $group = '', $start = 0, $limit = 100000)
    {
        return Db::name('order_insured')->where($where)->group($group)->field($field)->select();
    }
}